home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / a_utils / perl / perl5a1.lha / perl5alpha1 / do / eof < prev    next >
Encoding:
Text File  |  1992-08-15  |  829 b   |  46 lines

  1. bool
  2. do_eof(stab)
  3. STAB *stab;
  4. {
  5.     register STIO *stio;
  6.     int ch;
  7.  
  8.     if (!stab) {            /* eof() */
  9.     if (argvstab)
  10.         stio = stab_io(argvstab);
  11.     else
  12.         return TRUE;
  13.     }
  14.     else
  15.     stio = stab_io(stab);
  16.  
  17.     if (!stio)
  18.     return TRUE;
  19.  
  20.     while (stio->ifp) {
  21.  
  22. #ifdef STDSTDIO            /* (the code works without this) */
  23.     if (stio->ifp->_cnt > 0)    /* cheat a little, since */
  24.         return FALSE;        /* this is the most usual case */
  25. #endif
  26.  
  27.     ch = getc(stio->ifp);
  28.     if (ch != EOF) {
  29.         (void)ungetc(ch, stio->ifp);
  30.         return FALSE;
  31.     }
  32. #ifdef STDSTDIO
  33.     if (stio->ifp->_cnt < -1)
  34.         stio->ifp->_cnt = -1;
  35. #endif
  36.     if (!stab) {            /* not necessarily a real EOF yet? */
  37.         if (!nextargv(argvstab))    /* get another fp handy */
  38.         return TRUE;
  39.     }
  40.     else
  41.         return TRUE;        /* normal fp, definitely end of file */
  42.     }
  43.     return TRUE;
  44. }
  45.  
  46.